package cn.yunhe.dao;

import cn.yunhe.entity.Permission;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PermissionDao {

    @Select("select * from role_permission rp ,permission p where p.id=rp.permissionId and roleId = #{roleId}")
    List<Permission> findByRoleId(@Param("id") Integer roleId);

    @Select("select * from permission where id not in (select rp.permissionId from role_permission rp ,permission p where p.id=rp.permissionId and roleId = #{roleId})")
    List<Permission> findByRoleId2(@Param("id") Integer roleId);

    @Select("select * from permission where id in (select rp.permissionId from role_permission rp ,permission p where p.id=rp.permissionId and roleId = #{roleId})")
    List<Permission> findByRoleId3(@Param("id") Integer roleId);

    @Select("select * from permission")
    List<Permission> findAll();
    @Insert("insert into permission values (null,#{permissionName},#{url})")
    void save(Permission permission);
    @Delete("delete from permission where id = #{id}")
    void deletePermission(Integer id);

}
